package eteam.aps.service.impl;


import eteam.aps.common.entity.ParentEntity;
import eteam.aps.mapper.DataDictionaryCategoryMapper;
import eteam.aps.mapper.ProductParamMapper;
import eteam.aps.model.entity.ProductParam;
import eteam.aps.model.vo.ParamListVo;
import eteam.aps.model.vo.ParamVo;
import eteam.aps.model.vo.ProductParamVo;
import eteam.aps.service.ProductParamService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.*;

/**
 * 产品参数子表业务层
 *
 * @author WMT
 */
@Service
public class ProductParamServiceImpl implements ProductParamService {

    @Autowired
    private ProductParamMapper productParamMapper;

    @Autowired
    private DataDictionaryCategoryMapper dictionaryCategoryMapper;


    @Transactional
    @Override
    public int insert(List<ProductParam> params) {
        return productParamMapper.insert(params);
    }

    @Transactional
    @Override
    public int deleteByFDtlId(String fDtlId) {
        return productParamMapper.deleteByFDtlId(fDtlId);
    }

    @Transactional
    @Override
    public int deleteByFId(String fId) {
        return productParamMapper.deleteByFId(fId);
    }

    @Transactional
    @Override
    public int update(ProductParam productParam) {
        return productParamMapper.updateOne(productParam);
    }

    @Override
    public List<ProductParamVo> selectAll(String fDtlId) {
        Map<String,Object> map = new HashMap<>(2);
        map.put("fDtlId",fDtlId);
        map.put("fState",ParentEntity.FSTATE_DELETED);
        return productParamMapper.selectAll(map);
    }

    @Override
    public int countCodeByFDtlId(Map<String,Object> map) {
        return productParamMapper.countCodeByFDtlId(map);
    }


    @Override
    public Set<ParamListVo> selectParDd() {
        List<ParamListVo> paramListVos = productParamMapper.selectParDd(ParentEntity.FSTATE_DELETED);
        return new HashSet<>(paramListVos);
    }

    @Override
    public Set<ParamVo> selectDdInfo(String paramCode) {
        Map<String,Object> map = new HashMap<>(2);
        map.put("paramCode",paramCode);
        map.put("fState",ParentEntity.FSTATE_DELETED);
        List<ParamVo> paramVos = productParamMapper.selectDdInfo(map);
        return new HashSet<>(paramVos);
    }
}
